import cv2
import numpy as np

def img2vector(imgfilename):
    img = cv2.imread(imgfilename, cv2.IMREAD_GRAYSCALE )
    rows, columns = img.shape
    print(img.shape)
    vec = img.reshape(rows*columns)
    return vec

def distance(vector1, vector2):
    diff = vector1-vector2 # 差
    double_diff = diff**2 # 差平方
    sum_of_double_diff = double_diff.sum() # 差平方和
    dist = np.sqrt(sum_of_double_diff)
    return dist

t71 = "t-72-1.jpg"

bmp = "t-72-2.jpg"

vec1 = img2vector(t71)
vec2 = img2vector(bmp)

dis = distance(vec1,vec2)
print(dis)